﻿
using KC.Service.Core.EFService;
using KC.DTO.Account;
using KC.DTO.Core;
using Microsoft.AspNetCore.Identity;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using KC.Framework.Base;

namespace KC.Service.Account
{
    public interface IAccountService : IEFService
    {
        #region User
        Task<bool> ExistUserEmail(string eamil);
        Task<bool> ExistUserPhone(string phone);
        Task<bool> ExistUserName(string userName);

        List<UserDTO> GetAllUsersWithRolesAndOrgs();
        List<UserDTO> GetUsersByIds(List<string> userIds);

        List<UserDTO> GetUsersByRoleIds(List<string> userIds);
        List<UserDTO> GetUsersByNames(List<string> names);
        List<UserDTO> GetUsersByEmails(List<string> names);
        PaginatedBaseDTO<UserDTO> GetPaginatedUsersByFilter(int pageIndex, int pageSize, string email, string phone, string name, string statType, PositionLevel? positionLevel);
        PaginatedBaseDTO<UserDTO> GetPaginatedUsersPagedAgain(int pageIndex, int pageSize, List<UserDTO> list);
        PaginatedBaseDTO<UserDTO> GetPaginatedUsersByOrgIds(int pageIndex, int pageSize, List<int> list);

        UserDTO GetUserWithOrganizationsByUserId(string userId);
        UserDTO GetUserByUserName(string userName);
        UserDTO GetUserCheckId(string userId);
        UserContactInfoDTO GetUserContactInfoById(string userId);
        UserSimpleDTO GetSimpleUserWithOrgAndRoleNameByUserId(string userId);

        Task<IdentityResult> CreateUser(UserDTO data, string operatorId, string operatorName, string[] organizations, string gussourl);
        bool UpdateUser(UserDTO data, string operatorId, string operatorName, string[] organizations);
        bool RemoveUserById(string userId, string operatorId, string operatorName, Guid appid);
        bool UpdateRoleInUser(string userId, List<string> addList, string operatorId, string operatorName);

        #endregion

        #region DownLoad User Excel && Import User data from Excel
        bool ImportUserDataFromExcel(Stream excelData);

        #endregion
        
        Task<IdentityResult> ChangePasswordAsync(string userId, string currentPassword, string newPassword);
        Task<IdentityResult> ChangeAdminRawInfoAsync(string newPassword, string adminEmail, string adminPhone);
        Task<IdentityResult> ChangeMailPhoneAsync(string userId, string email, string phone);

        List<UserDTO> FindAllUsersNoInclude();
        List<UserDTO> FindAllUsersNoIncludeByUserId(List<string> userIds);

        #region AccountApi 登录 & 绑定微信号
        Task<UserDTO> GetUserByWxOpenIdAsync(string openId);
        Task<string> UpdateWxOpenIdAsync(string userId, string openId);
        Task<UserDTO> GetUserAndCheckAsync(string userName, string password);

        Task<UserDTO> GetUserAndCheckAsync(string openId);
        #endregion
    }
}
